'use strict';
const Utils = require('../../utils/Utils');
const BaseEntity = require("../../../libs/base/BaseEntity")

/**
 * 记录每一个生成的玩家的id以及对应的hall端口\游戏状态
 */
class Room {
    constructor() {
        this.pid = "";
        this.port = 0;
    }
    reset() {
        this.pid = "";
        this.hall = 0;
        this.name = "";
        this.game = 0;
        this.ip = "";
        this.password = "";
    }
}
/**
 * 记录每一个生成的玩家的id以及对应的hall端口\游戏状态
 */
class RoomManager extends BaseEntity {
    constructor() {
        super();
        this.RoomList = [];
        this.RoomPools = [];
        this.halls = [];//记录hall进程的port，
    }
    async init(name, serverConfig) {
        this.name = name;
        //获取hall端口列表，为hall负载均衡使用。
        const serviceConfig = serverConfig.find(p => p.name === "Hall");
        for (let j = 0; j < serviceConfig.number; j++) {
            this.halls.push(serviceConfig.port + j);
        }
    }
}
module.exports = RoomManager;